﻿using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	// Token: 0x020017C6 RID: 6086
	internal class XMentorshipApplicationsView : DlgBase<XMentorshipApplicationsView, XMentorshipApplicationBehavior>
	{
		// Token: 0x17003890 RID: 14480
		// (get) Token: 0x0600FC20 RID: 64544 RVA: 0x003ABD44 File Offset: 0x003A9F44
		public override string fileName
		{
			get
			{
				return "GameSystem/Teachermessage";
			}
		}

		// Token: 0x17003891 RID: 14481
		// (get) Token: 0x0600FC21 RID: 64545 RVA: 0x003ABD5C File Offset: 0x003A9F5C
		public override int layer
		{
			get
			{
				return 1;
			}
		}

		// Token: 0x17003892 RID: 14482
		// (get) Token: 0x0600FC22 RID: 64546 RVA: 0x003ABD70 File Offset: 0x003A9F70
		public override int group
		{
			get
			{
				return 1;
			}
		}

		// Token: 0x17003893 RID: 14483
		// (get) Token: 0x0600FC23 RID: 64547 RVA: 0x003ABD84 File Offset: 0x003A9F84
		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		// Token: 0x0600FC24 RID: 64548 RVA: 0x003ABD97 File Offset: 0x003A9F97
		protected override void Init()
		{
			this.InitProperties();
		}

		// Token: 0x0600FC25 RID: 64549 RVA: 0x003ABDA1 File Offset: 0x003A9FA1
		protected override void OnUnload()
		{
			base.OnUnload();
		}

		// Token: 0x0600FC26 RID: 64550 RVA: 0x003ABDAB File Offset: 0x003A9FAB
		public override void RegisterEvent()
		{
			base.RegisterEvent();
		}

		// Token: 0x0600FC27 RID: 64551 RVA: 0x003ABDB5 File Offset: 0x003A9FB5
		protected override void OnShow()
		{
			base.OnShow();
			XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOp_Get, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			base.uiBehaviour.OneShotBtn.gameObject.SetActive(false);
		}

		// Token: 0x0600FC28 RID: 64552 RVA: 0x003ABDE8 File Offset: 0x003A9FE8
		public void RefreshUI()
		{
			int beenApplyMsgCount = XMentorshipDocument.Doc.GetBeenApplyMsgCount();
			base.uiBehaviour.WrapContent.SetContentCount(beenApplyMsgCount, false);
			base.uiBehaviour.scrollView.ResetPosition();
			base.uiBehaviour.OneShotBtn.gameObject.SetActive(XMentorshipDocument.Doc.GetBeenApplyReportsMsgCount() > 0);
		}

		// Token: 0x0600FC29 RID: 64553 RVA: 0x003ABE48 File Offset: 0x003AA048
		private void InitProperties()
		{
			base.uiBehaviour.CloseBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseView));
			base.uiBehaviour.ClearBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClearNews));
			base.uiBehaviour.WrapContent.RegisterItemInitEventHandler(new WrapItemInitEventHandler(this.OnWrapContentItemInit));
			base.uiBehaviour.WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnWrapContentItemUpdate));
			base.uiBehaviour.OneShotBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShotAcceptReports));
		}

		// Token: 0x0600FC2A RID: 64554 RVA: 0x003ABEE8 File Offset: 0x003AA0E8
		private bool OnShotAcceptReports(IXUIButton button)
		{
			XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, 0UL, MentorMsgApplyType.MentorMsgApplyReportTask, 0, true);
			return true;
		}

		// Token: 0x0600FC2B RID: 64555 RVA: 0x003ABF0C File Offset: 0x003AA10C
		private bool OnClearNews(IXUIButton button)
		{
			XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Clear, 0UL, MentorMsgApplyType.MentorMsgApplyMax, 0, false);
			return true;
		}

		// Token: 0x0600FC2C RID: 64556 RVA: 0x003ABF30 File Offset: 0x003AA130
		private bool OnCloseView(IXUIButton button)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		// Token: 0x0600FC2D RID: 64557 RVA: 0x003ABF4C File Offset: 0x003AA14C
		private void OnWrapContentItemUpdate(Transform itemTransform, int index)
		{
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex(index);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				IXUILabel ixuilabel = itemTransform.Find("level").GetComponent("XUILabel") as IXUILabel;
				ixuilabel.SetText(beenApplyInfoByIndex.roleInfo.level.ToString());
				IXUISprite ixuisprite = itemTransform.Find("head").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.spriteName = XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon2((int)((int)beenApplyInfoByIndex.roleInfo.type % /*(RoleType)*/10));
				XFriendData friendDataById = DlgBase<XFriendsView, XFriendsBehaviour>.singleton.GetFriendDataById(beenApplyInfoByIndex.roleInfo.roleID);
				IXUISprite ixuisprite2 = itemTransform.Find("Profession").GetComponent("XUISprite") as IXUISprite;
				IXUILabelSymbol ixuilabelSymbol = itemTransform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
				IXUILabel ixuilabel2 = itemTransform.Find("Name").GetComponent("XUILabel") as IXUILabel;
				ixuisprite2.SetSprite(XSingleton<XProfessionSkillMgr>.singleton.GetProfIcon((int)((int)beenApplyInfoByIndex.roleInfo.type % /*(RoleType)*/10)));
				bool flag2 = friendDataById != null;
				if (flag2)
				{
					ixuilabelSymbol.InputText = XSingleton<XCommon>.singleton.StringCombine(XTitleDocument.GetTitleWithFormat(friendDataById.titleID, friendDataById.name), XWelfareDocument.GetMemberPrivilegeIconString(friendDataById.paymemberid), XRechargeDocument.GetVIPIconString(friendDataById.viplevel));
				}
				else
				{
					ixuilabelSymbol.InputText = "";
					ixuilabel2.SetText(beenApplyInfoByIndex.roleInfo.name);
				}
				IXUILabel ixuilabel3 = itemTransform.Find("MsgType").GetComponent("XUILabel") as IXUILabel;
				switch (beenApplyInfoByIndex.applyType)
				{
				case MentorMsgApplyType.MentorMsgApplyMaster:
					ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorMsgApplyMaster"));
					break;
				case MentorMsgApplyType.MentorMsgApplyStudent:
					ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorMsgApplyStudent"));
					break;
				case MentorMsgApplyType.MentorMsgApplyInherit:
					ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorMsgApplyInherit"));
					break;
				case MentorMsgApplyType.MentorMsgApplyReportTask:
				{
					MentorTaskTable.RowData tableTaskInfoByTaskID = XMentorshipDocument.Doc.GetTableTaskInfoByTaskID((uint)beenApplyInfoByIndex.reportTaskID);
					bool flag3 = tableTaskInfoByTaskID != null;
					if (flag3)
					{
						ixuilabel3.SetText(tableTaskInfoByTaskID.TaskName);
					}
					else
					{
						ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorPupilToReport"));
					}
					break;
				}
				case MentorMsgApplyType.MentorMsgApplyBreak:
					ixuilabel3.SetText(XSingleton<XStringTable>.singleton.GetString("MentorMsgApplyBreak"));
					break;
				}
				IXUIButton ixuibutton = itemTransform.Find("RefuseBtn").GetComponent("XUIButton") as IXUIButton;
				ixuibutton.gameObject.SetActive(beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyStudent || beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyMaster);
				ixuibutton.ID = (ulong)((long)index);
				IXUIButton ixuibutton2 = itemTransform.Find("AcceptBtn").GetComponent("XUIButton") as IXUIButton;
				ixuibutton2.gameObject.SetActive(beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyStudent || beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyMaster);
				ixuibutton2.ID = (ulong)((long)index);
				bool flag4 = beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyInherit || beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyReportTask || beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyBreak;
				Transform transform = itemTransform.Find("OneBtn");
				transform.gameObject.SetActive(flag4);
				bool flag5 = flag4;
				if (flag5)
				{
					IXUIButton ixuibutton3 = transform.GetComponent("XUIButton") as IXUIButton;
					IXUILabel ixuilabel4 = itemTransform.Find("OneBtn/opStr").GetComponent("XUILabel") as IXUILabel;
					bool flag6 = beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyReportTask;
					if (flag6)
					{
						ixuibutton3.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickToAgreeReport));
						ixuilabel4.SetText(XSingleton<XStringTable>.singleton.GetString("AcceptReport"));
						ixuibutton3.ID = (ulong)((long)index);
					}
					else
					{
						bool flag7 = beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyInherit;
						if (flag7)
						{
							ixuibutton3.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickToInherit));
							ixuilabel4.SetText(XSingleton<XStringTable>.singleton.GetString("ToAccept"));
							ixuibutton3.ID = (ulong)((long)index);
						}
						else
						{
							bool flag8 = beenApplyInfoByIndex.applyType == MentorMsgApplyType.MentorMsgApplyBreak;
							if (flag8)
							{
								ixuibutton3.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickToBreak));
								ixuilabel4.SetText(XSingleton<XStringTable>.singleton.GetString("ToConfirm"));
								ixuibutton3.ID = (ulong)((long)index);
							}
						}
					}
				}
			}
		}

		// Token: 0x0600FC2E RID: 64558 RVA: 0x003AC3B0 File Offset: 0x003AA5B0
		private bool OnClickToBreak(IXUIButton button)
		{
			int index = (int)button.ID;
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex(index);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, beenApplyInfoByIndex.roleInfo.roleID, beenApplyInfoByIndex.applyType, 0, false);
			}
			return true;
		}

		// Token: 0x0600FC2F RID: 64559 RVA: 0x003AC400 File Offset: 0x003AA600
		private bool OnClickToInherit(IXUIButton button)
		{
			int index = (int)button.ID;
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex(index);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, beenApplyInfoByIndex.roleInfo.roleID, beenApplyInfoByIndex.applyType, 0, false);
			}
			return true;
		}

		// Token: 0x0600FC30 RID: 64560 RVA: 0x003AC450 File Offset: 0x003AA650
		private void OnWrapContentItemInit(Transform itemTransform, int index)
		{
			IXUIButton ixuibutton = itemTransform.Find("RefuseBtn").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRefuseApply));
			IXUIButton ixuibutton2 = itemTransform.Find("AcceptBtn").GetComponent("XUIButton") as IXUIButton;
			ixuibutton2.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnAcceptApply));
		}

		// Token: 0x0600FC31 RID: 64561 RVA: 0x003AC4BC File Offset: 0x003AA6BC
		private bool OnClickToAgreeReport(IXUIButton button)
		{
			int index = (int)button.ID;
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex(index);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, beenApplyInfoByIndex.roleInfo.roleID, beenApplyInfoByIndex.applyType, beenApplyInfoByIndex.reportTaskID, false);
			}
			return true;
		}

		// Token: 0x0600FC32 RID: 64562 RVA: 0x003AC510 File Offset: 0x003AA710
		private bool OnAcceptApply(IXUIButton button)
		{
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex((int)button.ID);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Agree, beenApplyInfoByIndex.roleInfo.roleID, beenApplyInfoByIndex.applyType, 0, false);
			}
			return true;
		}

		// Token: 0x0600FC33 RID: 64563 RVA: 0x003AC55C File Offset: 0x003AA75C
		private bool OnRefuseApply(IXUIButton button)
		{
			MentorBeenApplyedInfo beenApplyInfoByIndex = XMentorshipDocument.Doc.GetBeenApplyInfoByIndex((int)button.ID);
			bool flag = beenApplyInfoByIndex != null;
			if (flag)
			{
				XMentorshipDocument.Doc.SendCandidatesOpReq(EMentorMsgOpType.EMentorMsgOpType_Reject, beenApplyInfoByIndex.roleInfo.roleID, beenApplyInfoByIndex.applyType, 0, false);
			}
			return true;
		}
	}
}
